﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CounttheNumberofConsistentStrings
{
    public class Solution
    {
        public int CountConsistentStrings(string allowed, string[] words)
        {
            var allowedList = allowed.ToList();
            var count = 0;
            foreach (var w in words)
            {
                if (IsConsistent(allowedList, w))
                {
                    count++;
                }
            }

            return count;
        }

        private bool IsConsistent(List<char> allowed, string target)
        {
            foreach (var c in target)
            {
                if (!allowed.Contains(c))
                {
                    return false;
                }
            }
            return true;
        }
    }
}
